<template>
  <eui-page-frame :topHeight="100" class="main-view">
    <template #top>
      <view style="background-color:white;">
        <!-- <eui-nav-bar title='调拨列表' backgroundColor='white' color='black' rightIcon='' /> -->
       	<eui-nav-bar rightIcon="" color="black" rightComponent="" style="margin-left:30rpx">
					<template #titleExpand>
						 <eui-tab 
              :tabs="topTabData" 
              :spaceLeft="spaceLeft" 
              :value="topTabIndex" 
              @change="topTabChange" 
              :tabStyle="tabStyle"></eui-tab>
					</template>
				</eui-nav-bar>
      
         <view class="top">
            <eui-search-bar
              ref="RdsSearchBar"
              v-model="c_id"
              class="uni-mt-10"
              radius="10"
              placeholder="请输入单据号"
              clearButton="none"
              @confirm="handleSearch"
              showFilterTitle="筛选条件"
              filterButton
              showFilterPopupTop
              :filterFormArr="filterFormArr" 
              @onFilterConfirm="onFilterConfirm"
            >
            </eui-search-bar>
            <eui-tab
              :tabs="tabData"
              :value="tabIndex"
              @change="tabChange"
            ></eui-tab>
          </view>
      </view>
    </template>
    <eui-page-content>

      <scroll-view   style="width: 100%;box-sizing: border-box;overflow-y: scroll;"
       :refresher-triggered="triggered"   @scrolltolower="templateLower"  @refresherrefresh="onRefresh">
          <view class="main">
            <eui-card
              v-for="(item,index) in dataList"
              :key="index"
              :optionData="item"
              type="receiptMth"
            >
              <view class="receiptTop">
                <view class>制单人：{{item.c_mk_username}}</view>
                <view>{{dateRangUtil.formatDate(item.c_mk_dt,'YYYY-MM-DD HH:mm:ss')}}</view>
              </view>
              <view class="receiptMain">
                <view class="storeNameClass storeNameClassTop">调出门店：{{item.c_s_store_name}}</view>
                <view class="storeNameClass">
                  共
                  <span class="num">xx</span>种商品
                  <span class="num">{{item.c_number_m}}</span>件，金额：
                  <span class="price">¥{{item.c_m_amount_m}}</span>
                </view>
              </view>

              <eui-button
                v-if="item.c_status == '尚未审核'"
                type="primary-mth"
                title="催办"
                @buttonClick="buttonClick"
                singleTag="primary_主按钮"
              />
            </eui-card>

          </view>
          <eui-float-icon
            :floatIconContent="floatIconContent"
            @floatIconItemClick="floatIconItemClick"
          >
          </eui-float-icon>
      </scroll-view>
     
    </eui-page-content>
  </eui-page-frame>
</template>

<script setup lang="ts">
import { ref, reactive } from "vue";
import { onLoad, onShow } from '@dcloudio/uni-app';

import dateRangUtil from '@/common/dateRangUtil';
import { getRdsUrl, rdsRequest } from "@/hooks/rdsServices";
import {useMainStore} from "@/store/modules/store"
const mainStore = useMainStore()
const { loginInfo } = mainStore
interface TabItem {
  name: string;
}

interface FilterOption {
  label: string;
  value: number | null;
  text?: string;
}

interface filterFormArr {
  title: string;
  type: string;
  value: number | null;
  options: FilterOption[];
}

const rdsUrl = getRdsUrl();

const triggered = ref(false);

const spaceLeft = ref(0);


const RdsSearchBar = ref();

// 头部 tab
const topTabIndex = ref(0);
const topTabData = ref<TabItem[]>([
  { name: "调入门店" }, 
  { name: "调出门店" }
]);

// 浮动按钮
const floatIconContent = ref<TabItem[]>([
    {
      text: '新增商品'
    },
    {
      text: '新增部门'
    }
]);

// 列表 tab数据
const tabIndex = ref(0);
const tabData = ref<TabItem[]>([
  { name: "全部" },
  { name: "尚未审核" },
  { name: "已审核" },
  { name: "已作废" },
]);

// 筛选条件
const filterFormArr = ref<filterFormArr[]>([
  {
    title: "表单",
    type: "radio",
    key: "c_status",
    value: null,
    options: [
      {
        label: "全部",
        value: null
      },
      {
        label: "尚未审核",
        value: "尚未审核"
      },
      {
        label: "已审核",
        value: "已审核"
      },
      {
        label: "已作废",
        value: "已作废"
      }
     
    ]
  },
  {
    title: "配送状态",
    type: "radio",
    key: "c_m_status",
    value: null,
    options: [
      {
        label: "全部",
        value: null
      },
      {
        label: "尚未发货",
        value: "尚未发货"
      },
      {
        label: "运输在途",
        value: "运输在途"
      },
      {
        label: "已收货",
        value: "已收货"
      },
    ]
  },
  {
    title: "调入门店",
    type: "select",
    value: null,
    key: "c_d_store_id",
    options: []
  },

  {
    title: "制单人",
    type: "input",
    value: null,
    key: "c_mk_username",
  },
  
]);
// 筛选数据
const filterParams = ref({
    c_status: null,
    c_m_status: null,
    c_d_store_id: null,
    c_mk_username: null
  });


const pageList = ref({
  CurrentPage: 1, //第几页
  RowsCount: 0, //总条数
  PageCount: 1, //总页数
})
const PageSize = ref(20)
const tabStyle = ref({ justifyContent: 'flex-start',});
const c_id = ref(""); //列表卡片 列表
const options = ref([]); //列表卡片 列表
const dataList = ref({}); //列表卡片 数据
const departmentList = ref([]); //部门 数据

// 头部 tab 事件
const topTabChange = (e: number) => {
  topTabIndex.value = e;
  pageList.value.CurrentPage = 1;
  dataList.value = [];
  console.log("pageList",pageList.value)

  getOptionData();
};

// 列表 tab 事件
const tabChange = (e: number) => {
  tabIndex.value = e;
  getOptionData();

};



// 加载更多
const templateLower = () => {
    if (pageList.value.CurrentPage < pageList.value.PageCount) {
        pageList.value.CurrentPage = pageList.value.CurrentPage + 1;
        getOptionData();
    }
}

// 刷新
const onRefresh = (e: number) => {
   if (!triggered.value) {
        triggered.value = true;
        
		pageList.value.CurrentPage = 1;
		dataList.value = [];
        getOptionData();
        setTimeout(() => {
            triggered.value = false;
        }, 600)
    }
};

/**
 * 获取部门数据
 */
const getDepartmentData = async () => {

    uni.showLoading({ title: "加载中...", mask: true })
    const result = await rdsRequest(rdsUrl.apiApi, '管易通60RMIS公共', 'GetUserStoreDepart', { Id: loginInfo.sUser })
    uni.hideLoading()
    
  
    // let result={ds2 : [   {
    //             "c_store_id": "0",
    //             "c_name": "山西美特好连锁超市有限公司总部",
    //             "lon": null,
    //             "lat": null
    //         },
    //         {
    //             "c_store_id": "1",
    //             "c_name": "山西美特好连锁超市有限公司总部",
    //             "lon": null,
    //             "lat": null
    //         },
    //         {
    //             "c_store_id": "11",
    //             "c_name": "山西分区总部",
    //             "lon": null,
    //             "lat": null
    //         },
    //         {
    //             "c_store_id": "1101",
    //             "c_name": "美特好迎宾店",
    //             "lon": "112.588936",
    //             "lat": "37.817053"
    //         },
    //         {
    //             "c_store_id": "1102",
    //             "c_name": "美特好滨河店",
    //             "lon": "112.541708",
    //             "lat": "37.890084"
    //         },]
    //         }
      
 
     
      departmentList.value = result.ds2.map((item: any) => ({
        text:item.c_name,
        label:item.c_name,
        value:item.c_store_id,
        checked: false
    }))
    filterFormArr.value[2].options = departmentList.value

    console.log('departmentList', departmentList.value)
}

// 获取列表数据
const getOptionData = async () => {
  RdsSearchBar.value?.onFilterCancel();

  try {
    const request = {
      c_id: c_id.value,
      IsNotPage: false,
      PageSize: PageSize.value,
      ...pageList.value,
      ...filterParams.value
    };  
      if(topTabIndex.value == 0){
        request.StoreId = loginInfo.sUser
      }else{
        request.SourceId = loginInfo.sUser
      }
      console.log("request",request)

    if(tabIndex.value != 0){
        request.c_status = tabData.value[tabIndex.value].name
    }

    // 使用真实API调用
    const result = await rdsRequest(rdsUrl.apiApi, '管易通60RMIS商品调拨', 'GetGdsTuneBilllst', request);
    
    // 模拟数据...
    //   const result = {
    //   ReturnObject: [
    //     {
    //       c_id: "AC25010400009",
    //       c_source_id: null,
    //       c_s_store_id: "1108",
    //       c_d_store_id: "1172",
    //       c_adno: "",
    //       c_type: "店间调拨",
    //       c_delivery_type: "直送",
    //       c_mk_store_id: "1108",
    //       c_mk_dt: "2025-01-04 16:41:30.530",
    //       c_mk_userno: "0000",
    //       c_au_dt: null,
    //       c_au_userno: null,
    //       c_s_dt: "2025-01-04 16:41:30.530",
    //       c_s_userno: "0000",
    //       c_d_dt: null,
    //       c_d_userno: null,
    //       c_charge_userno: null,
    //       c_s_username: "员工000",
    //       c_d_username: null,
    //       c_t_username: null,
    //       c_vehicle: null,
    //       c_route: null,
    //       c_status: "尚未审核",
    //       c_m_status: "尚未发货",
    //       c_print_status: null,
    //       c_note: "管易通录入",
    //       c_approve_status: "尚未审批",
    //       c_approve_dt: null,
    //       c_site: "本部",
    //       c_reason_om: null,
    //       c_present_BillId: null,
    //       c_order_billid: null,
    //       c_dc_site: "本部",
    //       c_wms_id: null,
    //       c_send_wms: null,
    //       c_req_number_m: 0.0,
    //       c_number_m: 482.0,
    //       c_fact_number_m: 1.0,
    //       c_fact_number_free_m: null,
    //       c_m_amount_m: 34.33,
    //       c_at_amount_m: 34.33,
    //       c_at_invoice: null,
    //       c_pay_status: null,
    //       c_urgent_type: "紧急调拨",
    //       c_source_type: null,
    //       c_provider: null,
    //       c_d_adno: "",
    //       c_delivery_dt: null,
    //       c_d_status: null,
    //       c_d_au_dt: null,
    //       c_d_au_userno: null,
    //       c_wave: null,
    //       c_dname: null,
    //       c_d_dname: null,
    //       c_d_store_name: "产业街",
    //       c_s_store_name: "漪汾店",
    //       c_mk_username: "员工000",
    //       c_au_username: "员工000"
    //     },
    //     {
    //       c_id: "AC25010400008",
    //       c_source_id: "AC25010400006",
    //       c_s_store_id: "1108",
    //       c_d_store_id: "1172",
    //       c_adno: "",
    //       c_type: "店间调拨",
    //       c_delivery_type: "直送",
    //       c_mk_store_id: "1108",
    //       c_mk_dt: "2025-01-04 16:27:08.303",
    //       c_mk_userno: "0000",
    //       c_au_dt: null,
    //       c_au_userno: null,
    //       c_s_dt: "2025-01-04 16:27:08.303",
    //       c_s_userno: "0000",
    //       c_d_dt: null,
    //       c_d_userno: null,
    //       c_charge_userno: null,
    //       c_s_username: "员工000",
    //       c_d_username: null,
    //       c_t_username: null,
    //       c_vehicle: null,
    //       c_route: null,
    //       c_status: "尚未审核",
    //       c_m_status: "尚未发货",
    //       c_print_status: null,
    //       c_note: "管易通录入",
    //       c_approve_status: "尚未审批",
    //       c_approve_dt: null,
    //       c_site: "本部",
    //       c_reason_om: null,
    //       c_present_BillId: null,
    //       c_order_billid: null,
    //       c_dc_site: "本部",
    //       c_wms_id: null,
    //       c_send_wms: null,
    //       c_req_number_m: 0.0,
    //       c_number_m: 482.0,
    //       c_fact_number_m: 1.0,
    //       c_fact_number_free_m: null,
    //       c_m_amount_m: 34.33,
    //       c_at_amount_m: 34.33,
    //       c_at_invoice: null,
    //       c_pay_status: null,
    //       c_urgent_type: "紧急调拨",
    //       c_source_type: null,
    //       c_provider: null,
    //       c_d_adno: "",
    //       c_delivery_dt: null,
    //       c_d_status: null,
    //       c_d_au_dt: null,
    //       c_d_au_userno: null,
    //       c_wave: null,
    //       c_dname: null,
    //       c_d_dname: null,
    //       c_d_store_name: "产业街",
    //       c_s_store_name: "漪汾店",
    //       c_mk_username: "员工000",
    //       c_au_username: "员工000"
    //     },
    //     {
    //       c_id: "AC25010400007",
    //       c_source_id: null,
    //       c_s_store_id: "1108",
    //       c_d_store_id: "1172",
    //       c_adno: "",
    //       c_type: "店间调拨",
    //       c_delivery_type: "直送",
    //       c_mk_store_id: "1108",
    //       c_mk_dt: "2025-01-04 15:23:10.127",
    //       c_mk_userno: "0000",
    //       c_au_dt: null,
    //       c_au_userno: null,
    //       c_s_dt: "2025-01-04 15:23:10.127",
    //       c_s_userno: "0000",
    //       c_d_dt: null,
    //       c_d_userno: null,
    //       c_charge_userno: null,
    //       c_s_username: "员工000",
    //       c_d_username: null,
    //       c_t_username: null,
    //       c_vehicle: null,
    //       c_route: null,
    //       c_status: "尚未审核",
    //       c_m_status: "尚未发货",
    //       c_print_status: null,
    //       c_note: "管易通录入",
    //       c_approve_status: "正在审批",
    //       c_approve_dt: "2025-01-04 15:36:34.103",
    //       c_site: "本部",
    //       c_reason_om: null,
    //       c_present_BillId: null,
    //       c_order_billid: null,
    //       c_dc_site: "本部",
    //       c_wms_id: null,
    //       c_send_wms: null,
    //       c_req_number_m: 0.0,
    //       c_number_m: 483.0,
    //       c_fact_number_m: 1.0,
    //       c_fact_number_free_m: null,
    //       c_m_amount_m: 34.33,
    //       c_at_amount_m: 34.33,
    //       c_at_invoice: null,
    //       c_pay_status: null,
    //       c_urgent_type: "紧急调拨",
    //       c_source_type: null,
    //       c_provider: null,
    //       c_d_adno: "",
    //       c_delivery_dt: null,
    //       c_d_status: null,
    //       c_d_au_dt: null,
    //       c_d_au_userno: null,
    //       c_wave: null,
    //       c_dname: null,
    //       c_d_dname: null,
    //       c_d_store_name: "产业街",
    //       c_s_store_name: "漪汾店",
    //       c_mk_username: "员工000",
    //       c_au_username: "员工000"
    //     },
    //     {
    //       c_id: "AC25010400006",
    //       c_source_id: "",
    //       c_s_store_id: "1108",
    //       c_d_store_id: "1172",
    //       c_adno: "",
    //       c_type: "店间调拨",
    //       c_delivery_type: "直送",
    //       c_mk_store_id: "1108",
    //       c_mk_dt: "2025-01-04 13:14:58.870",
    //       c_mk_userno: "0000",
    //       c_au_dt: "2025-01-04 16:04:09.250",
    //       c_au_userno: "0000",
    //       c_s_dt: "2025-01-04 13:14:58.870",
    //       c_s_userno: "0000",
    //       c_d_dt: "2025-01-04 16:04:09.670",
    //       c_d_userno: "0000",
    //       c_charge_userno: null,
    //       c_s_username: "员工000",
    //       c_d_username: "员工000",
    //       c_t_username: null,
    //       c_vehicle: null,
    //       c_route: null,
    //       c_status: "已审核",
    //       c_m_status: "已收货",
    //       c_print_status: null,
    //       c_note: "管易通录入",
    //       c_approve_status: "审批已通过",
    //       c_approve_dt: "2025-01-04 16:00:59.920",
    //       c_site: "本部",
    //       c_reason_om: null,
    //       c_present_BillId: null,
    //       c_order_billid: null,
    //       c_dc_site: "本部",
    //       c_wms_id: null,
    //       c_send_wms: null,
    //       c_req_number_m: 0.0,
    //       c_number_m: 483.0,
    //       c_fact_number_m: 1.0,
    //       c_fact_number_free_m: 0.0,
    //       c_m_amount_m: 34.33,
    //       c_at_amount_m: 34.33,
    //       c_at_invoice: null,
    //       c_pay_status: null,
    //       c_urgent_type: "紧急调拨",
    //       c_source_type: null,
    //       c_provider: null,
    //       c_d_adno: "",
    //       c_delivery_dt: null,
    //       c_d_status: "已审核",
    //       c_d_au_dt: "2025-01-04 16:04:09.250",
    //       c_d_au_userno: "0000",
    //       c_wave: null,
    //       c_dname: null,
    //       c_d_dname: null,
    //       c_d_store_name: "产业街",
    //       c_s_store_name: "漪汾店",
    //       c_mk_username: "员工000",
    //       c_au_username: "员工000"
    //     },
    //     {
    //       c_id: "AC25010400005",
    //       c_source_id: "",
    //       c_s_store_id: "1108",
    //       c_d_store_id: "1172",
    //       c_adno: "",
    //       c_type: "店间调拨",
    //       c_delivery_type: "直送",
    //       c_mk_store_id: "1108",
    //       c_mk_dt: "2025-01-04 13:14:48.313",
    //       c_mk_userno: "0000",
    //       c_au_dt: null,
    //       c_au_userno: null,
    //       c_s_dt: "2025-01-04 13:14:48.313",
    //       c_s_userno: "0000",
    //       c_d_dt: null,
    //       c_d_userno: null,
    //       c_charge_userno: null,
    //       c_s_username: "员工000",
    //       c_d_username: null,
    //       c_t_username: null,
    //       c_vehicle: null,
    //       c_route: null,
    //       c_status: "尚未审核",
    //       c_m_status: "尚未发货",
    //       c_print_status: null,
    //       c_note: "管易通录入",
    //       c_approve_status: "尚未审批",
    //       c_approve_dt: null,
    //       c_site: "本部",
    //       c_reason_om: null,
    //       c_present_BillId: null,
    //       c_order_billid: null,
    //       c_dc_site: "本部",
    //       c_wms_id: null,
    //       c_send_wms: null,
    //       c_req_number_m: 0.0,
    //       c_number_m: 483.0,
    //       c_fact_number_m: 1.0,
    //       c_fact_number_free_m: null,
    //       c_m_amount_m: 34.33,
    //       c_at_amount_m: 34.33,
    //       c_at_invoice: null,
    //       c_pay_status: null,
    //       c_urgent_type: "紧急调拨",
    //       c_source_type: null,
    //       c_provider: null,
    //       c_d_adno: "",
    //       c_delivery_dt: null,
    //       c_d_status: null,
    //       c_d_au_dt: null,
    //       c_d_au_userno: null,
    //       c_wave: null,
    //       c_dname: null,
    //       c_d_dname: null,
    //       c_d_store_name: "产业街",
    //       c_s_store_name: "漪汾店",
    //       c_mk_username: "员工000",
    //       c_au_username: "员工000"
    //     },
    //     {
    //       c_id: "AC25010400004",
    //       c_source_id: "",
    //       c_s_store_id: "1108",
    //       c_d_store_id: "1172",
    //       c_adno: "",
    //       c_type: "店间调拨",
    //       c_delivery_type: "直送",
    //       c_mk_store_id: "1108",
    //       c_mk_dt: "2025-01-04 13:14:38.570",
    //       c_mk_userno: "0000",
    //       c_au_dt: null,
    //       c_au_userno: null,
    //       c_s_dt: "2025-01-04 13:14:38.570",
    //       c_s_userno: "0000",
    //       c_d_dt: null,
    //       c_d_userno: null,
    //       c_charge_userno: null,
    //       c_s_username: "员工000",
    //       c_d_username: null,
    //       c_t_username: null,
    //       c_vehicle: null,
    //       c_route: null,
    //       c_status: "尚未审核",
    //       c_m_status: "尚未发货",
    //       c_print_status: null,
    //       c_note: "管易通录入",
    //       c_approve_status: "尚未审批",
    //       c_approve_dt: null,
    //       c_site: "本部",
    //       c_reason_om: null,
    //       c_present_BillId: null,
    //       c_order_billid: null,
    //       c_dc_site: "本部",
    //       c_wms_id: null,
    //       c_send_wms: null,
    //       c_req_number_m: 0.0,
    //       c_number_m: 483.0,
    //       c_fact_number_m: 1.0,
    //       c_fact_number_free_m: null,
    //       c_m_amount_m: 34.33,
    //       c_at_amount_m: 34.33,
    //       c_at_invoice: null,
    //       c_pay_status: null,
    //       c_urgent_type: "紧急调拨",
    //       c_source_type: null,
    //       c_provider: null,
    //       c_d_adno: "",
    //       c_delivery_dt: null,
    //       c_d_status: null,
    //       c_d_au_dt: null,
    //       c_d_au_userno: null,
    //       c_wave: null,
    //       c_dname: null,
    //       c_d_dname: null,
    //       c_d_store_name: "产业街",
    //       c_s_store_name: "漪汾店",
    //       c_mk_username: "员工000",
    //       c_au_username: "员工000"
    //     },
    //     {
    //       c_id: "AC25010400003",
    //       c_source_id: "",
    //       c_s_store_id: "1108",
    //       c_d_store_id: "1172",
    //       c_adno: "",
    //       c_type: "店间调拨",
    //       c_delivery_type: "直送",
    //       c_mk_store_id: "1108",
    //       c_mk_dt: "2025-01-04 13:14:15.600",
    //       c_mk_userno: "0000",
    //       c_au_dt: null,
    //       c_au_userno: null,
    //       c_s_dt: "2025-01-04 13:14:15.600",
    //       c_s_userno: "0000",
    //       c_d_dt: null,
    //       c_d_userno: null,
    //       c_charge_userno: null,
    //       c_s_username: "员工000",
    //       c_d_username: null,
    //       c_t_username: null,
    //       c_vehicle: null,
    //       c_route: null,
    //       c_status: "尚未审核",
    //       c_m_status: "尚未发货",
    //       c_print_status: null,
    //       c_note: "管易通录入",
    //       c_approve_status: "尚未审批",
    //       c_approve_dt: null,
    //       c_site: "本部",
    //       c_reason_om: null,
    //       c_present_BillId: null,
    //       c_order_billid: null,
    //       c_dc_site: "本部",
    //       c_wms_id: null,
    //       c_send_wms: null,
    //       c_req_number_m: 0.0,
    //       c_number_m: 483.0,
    //       c_fact_number_m: 1.0,
    //       c_fact_number_free_m: null,
    //       c_m_amount_m: 34.33,
    //       c_at_amount_m: 34.33,
    //       c_at_invoice: null,
    //       c_pay_status: null,
    //       c_urgent_type: "紧急调拨",
    //       c_source_type: null,
    //       c_provider: null,
    //       c_d_adno: "",
    //       c_delivery_dt: null,
    //       c_d_status: null,
    //       c_d_au_dt: null,
    //       c_d_au_userno: null,
    //       c_wave: null,
    //       c_dname: null,
    //       c_d_dname: null,
    //       c_d_store_name: "产业街",
    //       c_s_store_name: "漪汾店",
    //       c_mk_username: "员工000",
    //       c_au_username: "员工000"
    //     },
    //     {
    //       c_id: "AC25010400002",
    //       c_source_id: "",
    //       c_s_store_id: "1108",
    //       c_d_store_id: "1172",
    //       c_adno: "",
    //       c_type: "店间调拨",
    //       c_delivery_type: "直送",
    //       c_mk_store_id: "1108",
    //       c_mk_dt: "2025-01-04 13:13:10.250",
    //       c_mk_userno: "0000",
    //       c_au_dt: null,
    //       c_au_userno: null,
    //       c_s_dt: "2025-01-04 13:13:10.250",
    //       c_s_userno: "0000",
    //       c_d_dt: null,
    //       c_d_userno: null,
    //       c_charge_userno: null,
    //       c_s_username: "员工000",
    //       c_d_username: null,
    //       c_t_username: null,
    //       c_vehicle: null,
    //       c_route: null,
    //       c_status: "尚未审核",
    //       c_m_status: "尚未发货",
    //       c_print_status: null,
    //       c_note: "管易通录入",
    //       c_approve_status: "尚未审批",
    //       c_approve_dt: null,
    //       c_site: "本部",
    //       c_reason_om: null,
    //       c_present_BillId: null,
    //       c_order_billid: null,
    //       c_dc_site: "本部",
    //       c_wms_id: null,
    //       c_send_wms: null,
    //       c_req_number_m: 0.0,
    //       c_number_m: 483.0,
    //       c_fact_number_m: 1.0,
    //       c_fact_number_free_m: null,
    //       c_m_amount_m: 34.33,
    //       c_at_amount_m: 34.33,
    //       c_at_invoice: null,
    //       c_pay_status: null,
    //       c_urgent_type: "紧急调拨",
    //       c_source_type: null,
    //       c_provider: null,
    //       c_d_adno: "",
    //       c_delivery_dt: null,
    //       c_d_status: null,
    //       c_d_au_dt: null,
    //       c_d_au_userno: null,
    //       c_wave: null,
    //       c_dname: null,
    //       c_d_dname: null,
    //       c_d_store_name: "产业街",
    //       c_s_store_name: "漪汾店",
    //       c_mk_username: "员工000",
    //       c_au_username: "员工000"
    //     },
    //     {
    //       c_id: "AC25010400001",
    //       c_source_id: "",
    //       c_s_store_id: "1101",
    //       c_d_store_id: "1122",
    //       c_adno: "",
    //       c_type: "店间调拨",
    //       c_delivery_type: "直送",
    //       c_mk_store_id: "0",
    //       c_mk_dt: "2025-01-04 11:53:15.120",
    //       c_mk_userno: "0000",
    //       c_au_dt: null,
    //       c_au_userno: null,
    //       c_s_dt: null,
    //       c_s_userno: null,
    //       c_d_dt: null,
    //       c_d_userno: null,
    //       c_charge_userno: null,
    //       c_s_username: null,
    //       c_d_username: null,
    //       c_t_username: null,
    //       c_vehicle: null,
    //       c_route: null,
    //       c_status: "尚未审核",
    //       c_m_status: "尚未发货",
    //       c_print_status: null,
    //       c_note: null,
    //       c_approve_status: "尚未审批",
    //       c_approve_dt: null,
    //       c_site: "本部",
    //       c_reason_om: null,
    //       c_present_BillId: null,
    //       c_order_billid: null,
    //       c_dc_site: "本部",
    //       c_wms_id: null,
    //       c_send_wms: null,
    //       c_req_number_m: null,
    //       c_number_m: null,
    //       c_fact_number_m: null,
    //       c_fact_number_free_m: null,
    //       c_m_amount_m: null,
    //       c_at_amount_m: null,
    //       c_at_invoice: null,
    //       c_pay_status: null,
    //       c_urgent_type: "紧急调拨",
    //       c_source_type: null,
    //       c_provider: null,
    //       c_d_adno: "",
    //       c_delivery_dt: null,
    //       c_d_status: null,
    //       c_d_au_dt: null,
    //       c_d_au_userno: null,
    //       c_wave: null,
    //       c_dname: null,
    //       c_d_dname: null,
    //       c_d_store_name: "兴华街店",
    //       c_s_store_name: "迎宾店",
    //       c_mk_username: "员工000",
    //       c_au_username: "员工000"
    //     },
    //     {
    //       c_id: "AC25010300001",
    //       c_source_id: "",
    //       c_s_store_id: "1108",
    //       c_d_store_id: "1172",
    //       c_adno: "",
    //       c_type: "店间调拨",
    //       c_delivery_type: "直送",
    //       c_mk_store_id: "1108",
    //       c_mk_dt: "2025-01-03 16:44:11.473",
    //       c_mk_userno: "0000",
    //       c_au_dt: null,
    //       c_au_userno: null,
    //       c_s_dt: "2025-01-03 16:44:11.473",
    //       c_s_userno: "0000",
    //       c_d_dt: null,
    //       c_d_userno: null,
    //       c_charge_userno: null,
    //       c_s_username: "员工000",
    //       c_d_username: null,
    //       c_t_username: null,
    //       c_vehicle: null,
    //       c_route: null,
    //       c_status: "尚未审核",
    //       c_m_status: "尚未发货",
    //       c_print_status: null,
    //       c_note: "管易通录入",
    //       c_approve_status: "尚未审批",
    //       c_approve_dt: null,
    //       c_site: "本部",
    //       c_reason_om: null,
    //       c_present_BillId: null,
    //       c_order_billid: null,
    //       c_dc_site: "本部",
    //       c_wms_id: null,
    //       c_send_wms: null,
    //       c_req_number_m: 0.0,
    //       c_number_m: 483.0,
    //       c_fact_number_m: 1.0,
    //       c_fact_number_free_m: null,
    //       c_m_amount_m: 34.33,
    //       c_at_amount_m: 34.33,
    //       c_at_invoice: null,
    //       c_pay_status: null,
    //       c_urgent_type: "紧急调拨",
    //       c_source_type: null,
    //       c_provider: null,
    //       c_d_adno: "",
    //       c_delivery_dt: null,
    //       c_d_status: null,
    //       c_d_au_dt: null,
    //       c_d_au_userno: null,
    //       c_wave: null,
    //       c_dname: null,
    //       c_d_dname: null,
    //       c_d_store_name: "产业街",
    //       c_s_store_name: "漪汾店",
    //       c_mk_username: "员工000",
    //       c_au_username: "员工000"
    //     }
    //   ],
    //   AggregateObject: null,
    //   RowsCount: 47,
    //   PageCount: 5,
    //   CurrentPage: 1,
    //   PageSize: 10,
    //   ErrorString: null
    //  };

    // console.log("result",result);

  
    dataList.value = result.ReturnObject;
    pageList.value.PageCount = result.CurrentPage;
  } catch (error) {
    console.error('获取数据失败:', error);
  }
};


const buttonClick = (item: any) => {
}


interface FloatIconClickItem {
  index: number;
  item: {
    text: string;
  }
}

// 浮动按钮 事件
const floatIconItemClick = (item: FloatIconClickItem) => {
  uni.navigateTo({
      url: item.index === 0 ? '/pages/BusiViews/CommonPage/search' : '/pages/BusiViews/CommonPage/department'
  })
}

// 搜索
const handleSearch = () => {
  pageList.value.CurrentPage = 1;
  dataList.value = [];
  getOptionData();
}

// 筛选确认
const onFilterConfirm = (confirmArr: any) => {


  let confirmArrObj = confirmArr.reduce((acc: any, curr: any) => {
    if(curr.value !== null) {
      acc[curr.key] = curr.value;
    }
    return acc;
  }, {});
  
   
  // 处理表单状态的特殊逻辑
  if(confirmArrObj.c_status) {
    const index = tabData.value.findIndex((tab: TabItem) => tab.name === confirmArrObj.c_status);
    if(index !== -1) {
      tabIndex.value = index;
    }
  }
  
  filterParams.value = confirmArrObj
  console.log('转换前数据:', confirmArr);
  console.log('转换后的过滤参数:', filterParams.value);

  // 重置页码并获取数据
  pageList.value.CurrentPage = 1;
  getOptionData();
}


onLoad( ()=> {
    handleSearch()
    getDepartmentData()
})



</script>

<style lang="scss" scoped>
@import '../../../main.scss';


::v-deep .white-main {
  margin: 0;
  border-radius: 0;
}
.nav-bar-content {
  width: auto;
  height: 230rpx;
  background: white;
  image {
    width: 180rpx;
    height: 54rpx;
    gap: 30rpx;
  }
}

.card {
  border-radius: 16rpx;
  margin: 20rpx;
  background-color: #ffffff;
}

.e-attachment {
  align-items: center;
  justify-content: center;
  display: flex;

  &__image {
    width: 230rpx;
    height: 230rpx;
    margin: 12rpx;
    border-radius: 10rpx;
  }
}

.main-view {
  background: #ffffff;
      
    .uni-navbar__content_view {
      position: absolute;
      top: 30rpx;
      left: 20rpx;
      align-items: center;
      flex-direction: row;
      // background-color: #FFFFFF;
    }
  .top {
    ::v-deep .active {
      color: #666666 !important;
      font-weight: 600;
    }
    ::v-deep .m-button-min {
      height: 56rpx !important;
      border-radius: 16rpx !important;
    }
  }
  .main {
    // height: calc(100vh - 44px);
    border-radius: 40rpx 40rpx 0 0;
    background: #f5f5f5;
    padding-top: 1rpx;
    .receiptTop{
      display: flex;
      justify-content: space-between;
      font-size: $uni-font-size-level4;
      font-family: $uni-font-family;
      font-weight: $uni-font-weight-level1;
      color: $uni-text-color-hint;
      line-height: 36rpx;
      padding-bottom: 20rpx;
      margin-top: 10rpx;
      margin-bottom: 20rpx;
      border-bottom: 2rpx solid #f2f3f5;
    }
    .receiptMain{
        margin-bottom: 20rpx;

      .storeNameClass{
        font-size: $uni-font-size-level3;
        font-family: $uni-font-family;
        font-weight: $uni-font-weight-level1;
        color: $uni-text-color-title;
        line-height: 40rpx;
        .num{
          font-size: $uni-font-size-level3;
          font-family: $uni-font-family;
          font-weight: $uni-font-weight-level2;
          color: $uni-text-color-secondary;
        }
        .price{
          font-size: $uni-font-size-level2;
          font-family: $uni-font-family;
          font-weight: $uni-font-weight-level2;
          color: $uni-color-error;
        }
      }
      .storeNameClassTop{
        margin-bottom: 10rpx;
      }
    }
  }
}
</style>